<!DOCTYPE html>
<html lang="zh-CN">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->
    <title>幸运大转盘</title>
    <script src="https://cdn.bootcss.com/jquery/1.12.4/jquery.min.js"></script>
    {js href='/public/static/layui/layui.js' /} {CSS href="/public/static/layui/css/layui.css" /}
    <!-- Bootstrap -->
    <link href="__ADDONSTATIC__/css/bootstrap.min.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!-- WARNING: Respond.js doesn't work if you view the page via file:// -->
    <!--[if lt IE 9]>
    <script src="https://cdn.bootcss.com/html5shiv/3.7.3/html5shiv.min.js"></script>
    <script src="https://cdn.bootcss.com/respond.js/1.4.2/respond.min.js"></script>
    <![endif]-->
</head>

<body>

    <div class="container" style="width:100%;padding:0px;">
        <div class="rows">
            <div class="ontent">
                <div class="table-responsive" style="overflow-x: hidden;">
                    <form class="form-horizontal" method="post" action="">
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">注意：中奖几率 填入50 = 50%。所有几率加起来必须等于100</div>
                        </div>
                        {foreach $prize as $key=>$vo }
                        <div class="form-group">
                            <label for="{$vo.prize_id}" class="col-sm-2 control-label">奖项{$key+1}:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" id="{$vo.prize_id}" placeholder="请输入奖品名称" name="{$vo.prize_id}[]" value="{$vo.prize_name}">
                            </div>
                            <label for="{$vo.odds}" class="col-sm-2 control-label">中奖几率:</label>
                            <div class="col-sm-3">
                                <input type="text" class="form-control" placeholder="请输入几率,100 = 100%" name="{$vo.prize_id}[]" value="{$vo.odds}">
                            </div>
                            <a href="{:addonUrl('delete')}?id={$vo.prize_id}&roll_id={$roll_id}"><button type ="button" class="btn btn-default btn-sm btn-danger">删除</button></a>
                        </div>
                        {/foreach}
                        <div class="form-group">
                            <div class="col-sm-offset-2 col-sm-10">
                                <button type="submit" class="btn btn-default">保存</button>
                                <a href="{:addonUrl('addPrize')}?roll_id={$roll_id}"><button type="button" class="btn btn-default">新增</button></a>
                            </div>
                        </div>
                    </form>
                </div>
                <div align="center">
                    <ul class='pagination'> </ul>
                </div>
            </div>
        </div>
    </div>



    <!-- jQuery (necessary for Bootstrap's JavaScript plugins) -->

    <!-- Include all compiled plugins (below), or include individual files as needed -->
    <script src="__ADDONSTATIC__/js/bootstrap.min.js"></script>

    <script>
        
        layui.use('layer', function () {
            var layer = layui.layer;
            $(".form-horizontal").submit(function () {
                var loadIndex = layer.load(1)
                
                $.post('{:addonUrl("setprize")}', $('.form-horizontal').serialize(), function (res) {
                    layer.close(loadIndex)
                    layer.alert(res.msg);
                    
                }).error(function (error) {
                    layer.alert('500 Internal Server Error');
                    layer.close(loadIndex)
                })
                return false;
            })
        });
    </script>
</body>

</html>